package com.simplegui.api.util;

import java.awt.event.KeyEvent;

public enum Key {
	 UP(KeyEvent.VK_UP)
	,DOWN(KeyEvent.VK_DOWN)
	,LEFT(KeyEvent.VK_LEFT)
	,RIGHT(KeyEvent.VK_RIGHT)
	,SPACE(KeyEvent.VK_SPACE)
	,W(KeyEvent.VK_W)
	,S(KeyEvent.VK_S)
	;
	
	private int value;

	private Key(int value) {
		this.value = value;
	}
	
	public static Key getFromKeyEvent(KeyEvent keyEvent) {
		if (keyEvent == null) return null;
		for (Key key : values()) {
			if (key.value == keyEvent.getKeyCode()){
				return key;
			}
		}
		return null;
	}
	
}
